package com.jxc.model.po;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

@MappedSuperclass
public abstract class IdEntity {
	/**
	 * 主键
	 * 
	 */
	protected Long id;

	public IdEntity() {
		super();
	}

	public IdEntity(Long id) {
		super();
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID", nullable = false, length = 50)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public boolean equals(Object arg0) {
		if (!(arg0 instanceof IdEntity))
			return false;
		IdEntity entity = (IdEntity) arg0;
		return new EqualsBuilder().append(this.getId(), entity.getId())
				.isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().hashCode();
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

}
